classdef cEpsilonGreedy
    properties
        epsilon;
    end
    
    methods
        function obj = cEpsilonGreedy(init_epsilon)
            obj.epsilon=init_epsilon;
        end
        
        function [obj] = setParam(obj,param)
            obj.epsilon=param;
        end
        
        function [arm] = getArm(obj,Q)
            k=length(Q);
            if(rand()<obj.epsilon)
                arm=ceil(rand()*k);
            else
                maxArms=find(Q==max(Q));
                arm=maxArms(ceil(rand()*length(maxArms)));
            end
        end
        
    end
    
end